import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod_test/app_router.dart';
import 'package:flutter_riverpod_test/model/cart.dart';

class HomeCartListItem extends StatelessWidget {
  const HomeCartListItem({super.key, required this.cart});
  final Cart cart;

  static double itemHeight = 44;

  toCartInfo() {
    AppNavigator.push(AppRoute.cartInfo, cart);
  }

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: toCartInfo,
      child: Column(
        children: [
          Expanded(
            child: Row(
              children: [
                const SizedBox(width: 10,),
                Expanded(
                  child: AutoSizeText(
                    cart.displayName,
                    maxLines: 1,
                    overflow: TextOverflow.ellipsis,
                  ),
                ),
                const Icon(
                  Icons.keyboard_arrow_right_rounded,
                  size: 18,
                ),
              ],
            ),
          ),
          const Padding(
            padding: EdgeInsets.symmetric(horizontal: 15),
            child: SizedBox(
              width: double.infinity,
              height: 0.5,
              child: DecoratedBox(
                decoration: BoxDecoration(
                    color: Colors.black12
                ),
              ),
            ),
          )
        ],
      ),
    );
  }
}
